package com.xunshibao.core.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Set;

import org.logicalcobwebs.proxool.ProxoolException;
import org.logicalcobwebs.proxool.configuration.JAXPConfigurator;

/**
 * 数据库连接池
 * @author wujianq
 *
 */
public class ProxoolConnectionPool {
	/**
	 * 
	 * @param set
	 * 	proxool文件名列表
	 * @throws ProxoolException
	 */
	public ProxoolConnectionPool (Set<String> set) throws ProxoolException, Exception {
		Iterator<String> iter = set.iterator();
		while(iter.hasNext()){
			String file = iter.next();
			JAXPConfigurator.configure(file, false);
		}
	}
	/**
	 * 获取连接
	 * @param name
	 * 	jndi名称
	 * @return
	 * @throws SQLException
	 */
	public Connection getConnection(String name) throws SQLException, Exception {
		return DriverManager.getConnection(name);
	}
	
}
